package md5

import (
	"crypto/hmac"
	"crypto/md5"
	"gitee.com/injoyai/goutil/crypt"
)

//Encrypt
//md5加密,默认hex
//000000,加密后为670b14728ad9902aecba32e22fa4f6bd
func Encrypt(s string) string {
	return crypt.New(md5.New()).EncryptHex(s)
}

func EncryptHex(s string) string {
	return crypt.New(md5.New()).EncryptHex(s)
}

func EncryptStr(s string) string {
	return crypt.New(md5.New()).EncryptStr(s)
}

func EncryptBase64(s string) string {
	return crypt.New(md5.New()).EncryptBase64(s)
}

func EncryptBytes(s string) []byte {
	return crypt.New(md5.New()).EncryptBytes(s)
}

/*

 */

// Hmac
//HmacMD5,默认hex
func Hmac(s string, key string) string {
	return crypt.New(hmac.New(md5.New, []byte(key))).EncryptHex(s)
}

func HmacHex(s string, key string) string {
	return crypt.New(hmac.New(md5.New, []byte(key))).EncryptHex(s)
}

func HmacStr(s string, key string) string {
	return crypt.New(hmac.New(md5.New, []byte(key))).EncryptStr(s)
}

func HmacBase64(s string, key string) string {
	return crypt.New(hmac.New(md5.New, []byte(key))).EncryptBase64(s)
}

//HmacBytes
//HmacMD5
func HmacBytes(s string, key string) []byte {
	return crypt.New(hmac.New(md5.New, []byte(key))).EncryptBytes(s)
}
